<template>
  <el-table :data="list" stripe style="width: 100%">
    <el-table-column prop="number" label="试题编号" width="180">
    </el-table-column>
    <el-table-column prop="subject" label="学科" width="180"> </el-table-column>
    <el-table-column prop="catalog" label="目录"> </el-table-column>
    <el-table-column prop="questionType" label="题型">
      <template slot-scope="{ row }">
        {{ row.questionType | initType }}
      </template>
    </el-table-column>
    <el-table-column prop="question" label="题干" width="500">
      <template slot-scope="{ row }">
        {{ row.question.substr(3, row.question.length - 7) }}
      </template>
    </el-table-column>
    <el-table-column prop="addDate" label="录入时间" width="300">
      <template slot-scope="{ row }">
        {{ new Date(row.addDate) | parseTime }}
      </template>
    </el-table-column>
    <el-table-column prop="difficulty" label="难度">
      <template slot-scope="{ row }">
        {{ row.difficulty | initDifficulty }}
      </template>
    </el-table-column>
    <el-table-column prop="creator" label="录入人"> </el-table-column>
    <el-table-column prop="chkState" label="审核状态">
      <template slot-scope="{ row }">
        {{ row.chkState | initChkState }}
      </template>
    </el-table-column>
    <el-table-column prop="catalog" label="审核意见"> </el-table-column>
    <el-table-column prop="chkUser" label="审核人"> </el-table-column>
    <el-table-column prop="catalog" label="发布状态"> </el-table-column>
    <el-table-column label="操作" sortable="" fixed="right" width="280">
      <!-- <template slot-scope="{ row }"> -->
      <template slot-scope="{ row }">
        <el-button type="text" size="small" @click="$emit('previewBtn', row)"
          >预览</el-button
        >
        <el-button type="text" size="small" disabled>审核</el-button>
        <!-- @click="$router.push(`/questions/new`)" -->
        <el-button type="text" size="small" @click="editBtn(row)"
          >修改</el-button
        >
        <el-button
          type="text"
          size="small"
          @click="$emit('choicePublish', row)"
          >{{ row.publishState === 1 ? '上架' : '下架' }}</el-button
        >
        <el-button type="text" size="small" @click="$emit('delQuestion', row)"
          >删除</el-button
        >
      </template>
    </el-table-column>
  </el-table>
</template>

<script>
export default {
  name: 'TabPane',
  props: {
    list: {
      type: Array
    }
  },
  methods: {
    editBtn (row) {
      this.$router.push(
        `/questions/new?id=${row.id}&subjectID=${row.subjectID}`
      )
    }
  }
}
</script>

<style></style>
